package GUI;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;


/**
 *
 * @author Administrator
 */
public class UrgenciasMain extends javax.swing.JPanel {

   JToolBar jtb = new JToolBar("barra");
   
    public UrgenciasMain() throws SQLException {
        initComponents();
        
        this.setSize(800, 600);
        this.setBackground(Color.LIGHT_GRAY);
        this.setVisible(true);
        
        ImageIcon icono1 = new ImageIcon(getClass().getResource("/imagenes/anadir.png"));
        final JButton jbRegistrar = new JButton(icono1);
        
        ImageIcon icono2 = new ImageIcon(getClass().getResource("/imagenes/modificar.png"));
        final JButton jbModificar = new JButton(icono2);
        
        ImageIcon icono3 = new ImageIcon(getClass().getResource("/imagenes/borrar.png"));
        final JButton jbBorrar = new JButton(icono3);
        
        ImageIcon icono4 = new ImageIcon(getClass().getResource("/imagenes/search.png"));
        final JButton jbConsultar = new JButton(icono4);
        
        jtb.add(jbRegistrar);
        jtb.add(jbModificar);
        jtb.add(jbBorrar);
        jtb.add(jbConsultar);
        
        jtb.setFloatable(false);
        
        this.add(jtb,BorderLayout.NORTH);
        
        JPanelRegistrarUrgencia jpru=new JPanelRegistrarUrgencia();
        JPanelModificarUrgencia jpmu=new JPanelModificarUrgencia();
        JPanelBorrarUrgencia jpBu=new JPanelBorrarUrgencia();
        JPanelConsultarUrgencia jpcu=new JPanelConsultarUrgencia();
        
        panelContenedor.add("RegistrarUrgencia",jpru);
        panelContenedor.add("ModificarUrgencia",jpmu);
        panelContenedor.add("BorrarUrgencia",jpBu);
        panelContenedor.add("ConsultarUrgencia",jpcu);
        this.add(panelContenedor);
        
        jbRegistrar.addActionListener(new java.awt.event.ActionListener() {
            
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiaPanel("RegistrarUrgencia");
                jbRegistrar.setFocusPainted(false);
            }
        });
        
        jbModificar.addActionListener(new java.awt.event.ActionListener() {
            
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiaPanel("ModificarUrgencia");
                jbModificar.setFocusPainted(false);
            }
        });
        
        jbBorrar.addActionListener(new java.awt.event.ActionListener() {
            
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiaPanel("BorrarUrgencia");
                jbBorrar.setFocusPainted(false);
            }
        });
        
        jbConsultar.addActionListener(new java.awt.event.ActionListener() {
            
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiaPanel("ConsultarUrgencia");
                jbConsultar.setFocusPainted(false);
            }
        });
    }
    
    private void cambiaPanel(String nombre){
        CardLayout cl = (CardLayout) panelContenedor.getLayout();
        cl.show(panelContenedor, nombre);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelContenedor = new javax.swing.JPanel();

        setLayout(new java.awt.BorderLayout());

        panelContenedor.setLayout(new java.awt.CardLayout());
        add(panelContenedor, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel panelContenedor;
    // End of variables declaration//GEN-END:variables
}
